/* Used to insert HTML pages into containers on the webpage.
	Created a dynamic menu system without reloading page.
	Fairly seamless to the user.
*/

var bustcachevar=1 //bust potential caching of external pages after initial request? (1=yes, 0=no)
var loadedobjects=""
var rootdomain="http://"+window.location.hostname
var bustcacheparameter=""

//URL - page we want inserted.
//containerid - container (div) that URL will go
function replacePage(url, containerid){
	var page_request = false
	if (window.XMLHttpRequest) 
		page_request = new XMLHttpRequest()
	else
		return false
	page_request.onreadystatechange=function(){
		loadpage(page_request, containerid)
		}
	if (bustcachevar) //Not gonna lie, got this off the internet but lost the page.
					//Needed away to prevent caching and this was a solution.
				//Why reinvent the wheel? If I need a source, feel free to request and
				//I will gladly try harder.
		bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
	page_request.open('GET', url+bustcacheparameter, true)
	page_request.send(null)
}

function loadpage(page_request, containerid){
	if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
		document.getElementById(containerid).innerHTML=page_request.responseText
}
